$(document).ready(function() {
	 var objs = document.getElementsByName("dormitoryNumberName");
	  check_val = [];
      for(k in objs){
    	  	var tmp11 = $.trim($(objs[k]).html());
            if(tmp11.length != 0){
            	$(objs[k]).parent().children("td").children("input:checkbox").attr("disabled","disabled");
            }
       }
	var dormitoryNumberId=$.trim($("#dormitoryNumberId").val());
	
		 $("#btnDistribution").click(function(){
			  obj = document.getElementsByName("checkboxName");
		       check_val = [];
		      for(k in obj){
		            if(obj[k].checked)
		              check_val.push(obj[k].value);
		       }
		      if(check_val.length!=0){
		    	  if(check_val.length<=6){
			 top.$.jBox.confirm("确认要分配房间吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						/* alert($("[name='checkboxName']:checkbox:checked").length);*/
					    	var idstr=check_val.join(',');//将数组元素连接起来以构建一个字符串   
					    	var ctx=$("#inputCtx").val();
							$("#searchForm").attr("action",ctx+"/students/dmsStudents/distributions?idstr="+idstr);
							$("#searchForm").submit();
					  } 
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
				}else jBox.confirm("选择人数不能超过6人！", "提示", { id:'hahaha', showScrolling: false, buttons: { '关闭': true } });
		      }else jBox.confirm("请选择学生！", "提示", { id:'hahaha', showScrolling: false, buttons: { '关闭': true } });
	  });

	  
	  
    $("#btnExport").click(function(){
		top.$.jBox.confirm("确认要导出用户数据吗？","系统提示",function(v,h,f){
			if(v=="ok"){
			var ctx=$("#inputCtx").val();
				$("#searchForm").attr("action",ctx+"/students/dmsStudents/export");
				$("#searchForm").submit();
			}
		},{buttonsFocus:1});
		top.$('.jbox-body .jbox-icon').css('top','55px');
	});
	$("#btnImport").click(function(){
		$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
			bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
	});
	
});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	/*	*//****************检查学号方法*****************/
		function checkStudentNumber(check_val){
			var returnVal = 111;
		$.ajax({
				url:ctx+"/students/dmsStudents/distributions",
				type:"post",
				data:"check_val="+check_val,
				async:false,
				success:function(data){
					
					returnVal = 222;
					/*if(data=="false"){
						var aaa =  layer.confirm('学号已经添加过了！', {
							"按钮"
							  btn: ['确定'] 
							}, function(){
							  layer.close(aaa); 
							});
					   
					} else{
						"验证成功"
						returnVal = 222;
					}*/
				}
			});
			return returnVal;
		}
		
		
		